/**
 * @file
 * @auth jinguangguo
 * @date 2016/10/28
 */

export default class noticeSvc {
    constructor(Api) {
        'ngInject';
        this.Api = Api;
    }

    /**
     * 列表
     * @param params
     * @returns {*}
     */
    list(params = {}) {
        return this.Api.get('/noticeApi/noticeList', params, null, false);
    }

    /**
     * 添加
     * @param param
     */
    add(param = {}) {
        /*
         "userId": 1,
         "nickname": "admin",
         "topStatus": "YES",
         "title": "公告标题",
         "content": "公告内容"
         */
        //
        return this.Api.post('/noticeApi/noticeCreate', param, null, false);
    }

    /**
     * 移除公告
     * @param param
     * @returns {*}
     */
    remove(param = {}) {
        return this.Api.get('/noticeApi/noticeDelete', param, null, false);
    }

    /**
     * 置顶
     * @param param
     * @returns {*}
     */
    top(param = {}) {
        /*
         request param
         {
         "noticeId":1,
         "topStatus":"YES"
         }
         */
        return this.Api.get('/noticeApi/top', param, null, false);
    }

    /**
     * 公告详情
     * @param param
     * @returns {*}
     */
    detail(param = {}) {
        /*
         request param
         noticeId
         */

        /*
         response
         {
         "noticeId":200,
         "userId":1,
         "nickname":"admin",
         "topStatus":"YES",
         "createTime":1,
         "title":"公告标题",
         "content":"公告内容"
         }
         */
        return this.Api.get(`/noticeApi/noticeDetail`, param, null, false);
    }

}
